package com.cctc.config.cors;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Name CorsConfigWithCorsRegistry
 * @Description: CORS [跨域资源共享] 配置
 * 使用 CorsRegistry 回调配置 CORS。
 * @Author: lichao
 * @Email: li2chao@126.com
 * @Date: 2024-01-24 20:14:41
 **/
@Configuration
public class CorsConfigWithCorsRegistry implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/api/**")
                .allowedOrigins("https://gulimall.com")
                .allowCredentials(true)
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
                .allowedHeaders("*")
                .maxAge(3600);
    }

}

